<template>
	<view class="page-wrap" :data-theme="theme" :class="theme" :style="globalColor.style">
		<HeadCustom :isAppBtn="false"></HeadCustom>
		<view class="wrap">
			<view class="title font46 font-weight">求职意向</view>
			<view class="tips mt16 font30 font-w300">信息越完善，匹配越准确</view>
			<!-- 求职意向 -->
			<view class="expect-wrap">
				<view class="expect-item" v-for="(item, index) in expectList" :key="index">
					<view class="tit font26 color-BF8355 flex1">{{ item.title }}</view>
					<view class="con mt20 lh50 fboxRow Ycenter" @click="expectTap(item)">
						<view class="flex1 font34 font-ell1">
							<text v-if="String(fromData[item.key]) && String(fromData[item.key]) != 'null'">
								<template v-if="item.key == 'salaryMin'">
									{{ fromData.salaryMin == 0 ? '面议' : fromData.salaryMin }}
									<template v-if="fromData.salaryMin != 0">
										- {{ fromData.salaryMax }}
									</template>
								</template>

								<template v-else-if="item.key == 'expectIndustryList'">
									{{ fromData.expectIndustryList.toString() }}
								</template>
								<template v-else-if="item.key == 'expectPositionList'">
									{{ fromData.expectPositionList.toString() }}
								</template>
								<template v-else>
									{{ fromData[item.key] }}
								</template>
							</text>
							<text v-else class="color-6B707C">{{ item.placeholder }}</text>
						</view>
						<text class="bwfont bw-arrow-right color-ACB4C7 font24"></text>
					</view>
					<view class="line"></view>
				</view>
				<PickerBlack type="salary" :isShow.sync="isSalary" @confirm="pickerSalary" />
			</view>
		</view>
		<BottomFixed>
			<view class="btn-group-inner flex1 fboxRow Ycenter Xcenter">
				<view class="btn flex1 fboxRow Ycenter Xcenter font30 color-141720 bg-linear" @click="save">保存</view>
			</view>
		</BottomFixed>
	</view>
</template>

<script>
import { sysAreaModuleList, resumeInfo } from '@/api/recruit.js';
import PickerBlack from '../components/picker-black.vue';
	import BottomFixed from '@/components/bottom-btn/fixed.vue'
import { recruitMixins } from '../common/recruit.mixins.js';
export default {
	mixins: [recruitMixins],
	components: { PickerBlack, BottomFixed },
	data() {
		return {
			theme: getApp().globalData.appTheme,
			globalColor: getApp().globalData.globalColor,
			fromData: {
				expectCityId: '',
				expectCityName: '',
				expectIndustryList: [],
				expectPositionList: [],
				salaryMax: '',
				salaryMin: ''
			},
			expectList: [
				{
					title: '期望城市',
					placeholder: '请选择期望城市',
					key: 'expectCityName'
				},
				{
					title: '期望职位',
					placeholder: '请选择期望职业',
					key: 'expectPositionList'
				},
				{
					title: '期望行业',
					placeholder: '请选择期望行业',
					key: 'expectIndustryList'
				},
				{
					title: '薪资要求',
					placeholder: '请选择薪资要求',
					key: 'salaryMin'
				}
			],
			isSalary: false
		};
	},
	onShow() {
		this.getInit();
	},
	methods: {
		getInit() {
			const vitaTemp = getApp().globalData.vitaTemp;
			console.log(vitaTemp, vitaTemp.hasOwnProperty('expectCityName'))
			if (vitaTemp.hasOwnProperty('expectCityName')) {
				this.fromData = vitaTemp;
			}else{
				resumeInfo().then(res => {
					if (res.data) {
						this.fromData = res.data;
						getApp().globalData.vitaTemp = res.data;
					}
				});
			}
		},
		pickerSalary(e) {
			this.isSalary = false;
			if (e.value[0] == '面议') {
				this.fromData.salaryMin = 0;
				this.fromData.salaryMax = 0;
			} else {
				this.fromData.salaryMin = e.value[0];
				this.fromData.salaryMax = e.value[1];
			}
		},
		expectTap(e) {
			getApp().globalData.vitaTemp = this.fromData;
			if (e.key == 'salaryMin') {
				this.isSalary = true;
			} else if (e.key == 'expectIndustryList') {
				this.$pageTo(`/recruit/common/industry?isCheckbox=1&&pageType=vita`);
			} else if (e.key == 'expectPositionList') {
				this.$pageTo(`/recruit/common/position?isCheckbox=1&&pageType=vita`);
			} else if (e.key == 'expectCityName') {
				this.$pageTo('/recruit/common/city?pageType=vita');
			}
		},
		save() {
			this.loading = true
			uni.showLoading({ title: '保存中', mask: true })
			this.postSave(this.fromData, 'back');
		}
	}
};
</script>

<style lang="scss" scoped>
.page-wrap {
	min-height: calc(100vh);
}

.title { line-height: 66rpx; color:var(--contourButtonTextColor) }
.tips { line-height: 44rpx; color: var(--contentFontLightColor) }
.tit{color:var(--contentFontDarkColor);}

.wrap {
	padding: 40rpx;
}

.uni-input {
	padding: 0 32rpx;
	width: 542rpx;
	height: 88rpx;
	background: var(--viewBgColor);
	border-radius: 12rpx;
}

.expect-wrap {
	padding-top: 64rpx;
}

.expect-item .line {
	margin: 40rpx 0;
	height: 1rpx;
	background: var(--backgroundDivisionColor);
}
.expect-item .bw-arrow-right{color: var(--contentFontFourColor)}

.btn-group-inner .btn {
	// margin: 0 24rpx;
	width: 570rpx;
	height: 76rpx;
	border-radius: 12rpx;
}
</style>
